package edu.uclm.esi.tysweb.ajedrez.persistencia;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Broker {
	private static Broker yo;
	private String url;
	
	private Broker() {
		try {
			Class.forName("com.mysql.jdbc.Driver");
			this.url="jdbc:mysql://localhost:3306/ajedrez";
		} catch (ClassNotFoundException e) { 
			System.out.println(e.toString());
		}
	}
	
	public static Broker get() {
		if (yo==null)
			yo=new Broker();
		return yo;
	}
	
	public Connection getDB(String user, String password) throws SQLException {
		return DriverManager.getConnection(url, user, password);
	}
}
